'\" te
.\"  Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SIP_GET_HEADER 3SIP "Feb 09, 2007"
.SH NAME
sip_get_header \- get a SIP header from a message
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsip\fR [ \fIlibrary\fR ... ]
#include <sip.h>

\fBconst struct sip_header *\fR\fIsip_get_header\fR(\fBsip_msg_t\fR \fIsip_msg\fR,
     \fBchar *\fR\fIheader_name\fR, \fBsip_header_t\fR \fIold_header\fR, \fBint *\fR\fIerror\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBsip_get_header()\fR function returns the header specified by
\fIheader_name\fR (long or compact form) from the \fBSIP\fR message
\fIsip_msg\fR. If \fIheader_name\fR is \fBNULL\fR, the first header in the
\fBSIP\fR message is returned. The \fBold_header\fR, if non-null, specifies the
starting position in \fIsip_msg\fR from which the search is started. Otherwise,
the search begins at the start of the \fBSIP\fR message. For example, to get
the first \fBVIA\fR header from the \fBSIP\fR message \fIsip_msg\fR:
.sp
.in +2
.nf
via_hdr = sip_get_header(sip_msg, "VIA", NULL, &error);
.fi
.in -2

.sp
.LP
To get the next \fBVIA\fR header from \fIsip_msg\fR:
.sp
.in +2
.nf
via_hdr = sip_get_header(sip_msg, "VIA", via_hdr, &error);
.fi
.in -2

.sp
.LP
The \fBsip_get_header()\fR function ignores any header that is marked as
deleted.
.SH RETURN VALUES
.sp
.LP
On success, the \fBsip_get_header()\fR function returns the queried header. On
failure, it returns \fBNULL\fR.
.sp
.LP
The value of \fBerrno\fR is not changed by these calls in the event of an
error.
.SH ERRORS
.sp
.LP
The following value may be returned:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIheader_name\fR specified in the \fBSIP\fR message is not present or has
been deleted; or, the \fIheader_name\fR is not specified and there are no
"un-deleted" headers in the \fBSIP\fR message.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR libsip (3LIB)
